#include <iostream>
#include <deque>
using namespace std;

int main() {
    int t = 0;
    cin >> t;
    cin.ignore();
    while (t--) {
        deque<int> ans;
        int n = 0;
        cin >> n;
        int x = 0;
        cin >> x;
        for (int i = 0; i < n; i++) {
            if (i == x) {
                continue;
            }
            if (i < x) {
                ans.push_front(i);
            }
            else if(i > x) {
                ans.push_back(i);
            }
        }
        ans.push_back(x);
        for (int i = 0; i < n-1; i++) {
            cout << ans[i] << ' ';
        }
        cout << ans[n-1] << endl;
    }

    return 0;
}